var currying = function(fn){
    var args = [];
    return function(){
        if(arguments.length ===0){
            console.log(0)
            return fn.apply(this,args)
        }else{
            [].push.apply(args,arguments);
            console.log(1,arguments.callee)
            return arguments.callee;
        }
    }
}
var cost = (function(){
    var money = 0;
    return function(){
        for(var i = 0,l=arguments.length;i<l;i++){
            money+= arguments[i]
        }
        console.log(money,'钱')
        return money
    }
})()

var costs = currying(cost) //转化成currying函数
costs(100)
costs(200)
costs(300)
console.log(costs())